package edu.hunan.cxb18.controller;

import edu.hunan.cxb18.pojo.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * @author AuthorName
 * @create 2020-04-01 10:36
 */
@RequestMapping("/user")
@Controller
public class LoginController {
    @RequestMapping(value = "/login",method = RequestMethod.POST)
    public String testUser(User user){
        System.out.println(user);
        return "success";
    }

    @RequestMapping("/loginview")
    public ModelAndView test() {
        ModelAndView mv = new ModelAndView();
        mv.setViewName("login");
        return mv;
    }

    @RequestMapping("/getuser/{id}")
    public String test01(@PathVariable("id") Integer id) {
        System.out.println(id);
        return "success";
    }

    @RequestMapping(value = "/RestGet/{id}", method = RequestMethod.GET)
    public String test02(@PathVariable("id") Integer id) {
        System.out.println("get" + id);
        return "success";
    }

    @RequestMapping(value = "/RestPost/{id}", method = RequestMethod.POST)
    public String test03(@PathVariable("id") Integer id) {
        System.out.println("post" + id);
        return "success";
    }

    @RequestMapping(value = "/DeleteRest/{id}", method = RequestMethod.DELETE)
    public String test04(@PathVariable("id") Integer id) {
        System.out.println("delete" + id);
        return "success";
    }

    @RequestMapping(value = "/PutRest/{id}", method = RequestMethod.PUT)
    public String test05(@PathVariable("id") Integer id) {
        System.out.println("put" + id);
        return "success";
    }

    @RequestMapping("/cookieValue")
    public String test06(
                          @CookieValue(name = "JSESSIONID", required = false) String cookieValue) {
        System.out.println(cookieValue);
        return "success";
    }

    @RequestMapping("/requestHeader")
    public String test07(
            @RequestHeader(name = "Content-Type") String requestHander) {
        System.out.println(requestHander);
        return "success";
    }
}
